<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data: function() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/health/score/scorestatement',
      // Web路径
      webPath: 'health/Health/Score/ScoreStatement',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userScoreCode",
              name: "用户积分编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "minBusinessTime",
              name: "最早业务时间",
              span: 6,
              type: "datetime",
              config: {
                edit: false
              }
            },
            {
              code: "maxBusinessTime",
              config: {
                edit: false
              },
              name: "最晚业务时间",
              span: 6,
              type: "datetime"
            },
            {
              code: "statementTypeSign",
              name: "流水状态标识",
              span: 6,
              type: "select",
              config: {
                edit: false,
                options: [
                  { key: "1", value: "增加" },
                  { key: "2", value: "减少" }
                ]
              }
            },
            {
              code: "scoreNum",
              name: "积分值",
              span: 6,
              type: "number",
              config: {
                edit: false,
                precision: 2
              }
            },
            {
              code: "reasonTypeCode",
              name: "原因类型编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "reasonTypeName",
              name: "原因类型名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "userScoreCode",
          name: "用户积分编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "businessTime",
          name: "最早业务时间",
          span: 6,
          type: "datetime",
          config: {
            edit: false
          }
        },
        {
          code: "statementTypeSign",
          name: "流水状态标识",
          span: 6,
          type: "select",
          config: {
            edit: false,
            options: [
              { key: "1", value: "增加" },
              { key: "2", value: "减少" }
            ]
          }
        },
        {
          code: "scoreNum",
          name: "积分值",
          span: 6,
          type: "number",
          config: {
            edit: false,
            precision: 2
          }
        },
        {
          code: "reasonTypeCode",
          name: "原因类型编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "reasonTypeName",
          name: "原因类型名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "sourceOrdCode",
          name: "依据单号",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userScoreCode",
              span: 6,
              name: "用户积分编码",
              type: "popup",
              config: {
                url: "health/health/score/userscore",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                rules: [
                  { required: true, message: '请选择用户', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("userScoreId", row.id)
                }
              }
            },
            {
              code: "businessTime",
              name: "业务时间",
              span: 6,
              type: "datetime",
              config: {
                edit: false
              }
            },
            {
              code: "statementTypeSign",
              name: "流水状态标识",
              span: 6,
              type: "select",
              config: {
                edit: false,
                options: [
                  { key: "1", value: "增加" },
                  { key: "2", value: "减少" }
                ]
              }
            },
            {
              code: "reasonTypeCode",
              span: 6,
              name: "原因类型编码",
              type: "popup",
              config: {
                url: "base/dictionary/datadic/datadictionary",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                rules: [
                  { required: true, message: '请选择原因类型编码', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  // const formData = {
                  //   reasonTypeName: row.name,
                  //   reasonTypeCode: row.code,
                  //   reasonTypeId: row.id
                  // }
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("reasonTypeName", row.name)
                  this.$refs.commonPage.updateFormData("reasonTypeId", row.id)
                }
              }
            },
            {
              code: "reasonTypeName",
              name: "原因类型编码",
              span: 6,
              type: "text",
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "scoreNum",
              name: "积分值",
              span: 6,
              type: "number",
              config: {
                edit: false,
                precision: 2
              }
            },
            {
              code: "sourceOrdCode",
              name: "依据单号",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
